Shading CG representations of materials

ABSTRACT

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for shading computer graphics (CG) representations of materials. One of the methods includes obtaining data describing a physical material; receiving a shading request to shade a particular point in a CG representation of the physical material from a rendering engine, wherein the request identifies a mapping position of the particular point, a view direction at the mapping position, and a light direction at the mapping position; calculating a direct lighting color at the mapping position using a plurality of palettized images; calculating an indirect lighting color at the mapping position using the data describing the physical material; generating a final color at the mapping position by combining the direct lighting color and the indirect lighting color; and providing the final color to the rendering engine for use in rendering the CG representation of the physical material.

BACKGROUND

This specification relates to shading computer graphics (CG)representations of materials. During the process of rendering a CGrepresentation of a material, one or more shading techniques can be usedto determine, e.g., the color and brightness of the surfaces of thematerial, based on the desired lighting in the rendered scene.

SUMMARY

In general, one innovative aspect of the subject matter described inthis specification can be embodied in an apparatus that includes a lightsource having a lens for emitting light; a plurality of first planarmirrors, wherein the light source is movable to directly illuminate eachplanar mirror of the plurality of first planar mirrors; a sample supportconfigured to suspend a material sample between the plurality of firstmirrors and the light source, wherein the sample support is positionedsuch that each of the first mirrors reflects a respective view of thematerial sample from a different perspective; and a camera proximate tothe light source and configured to capture a respective image of thefirst mirrors reflecting the material sample while the light source ispositioned to directly illuminate each of the planar mirrors.

These and other embodiments can each optionally include one or more ofthe following features. The emitted light can be collimated light.Directly illuminating a first planar mirror can include emitting lightfrom the lens of the light source that is reflected by a second mirrorto intersect the first planar mirror. The camera can be furtherconfigured to provide the images to a system for use in generating datastructures for shading a computer graphics representation of thematerial sample. The first planar mirrors can be arrayed so thatrespective surfaces of the first planar mirrors define an ellipsoid. Acenter of the material sample can be positioned at a first focal pointof an ellipse formed by taking a cross section of the ellipsoid thatpasses through a center of the ellipsoid and is along a semi-axis of theellipsoid. The camera can be positioned at a second focal point of theellipse. The light source can be mounted on a rotating disc.

In general, another innovative aspect of the subject matter described inthis specification can be embodied in methods that include the actionsof obtaining a plurality of first images, wherein each first imageincludes a plurality of regions, wherein each region corresponds to arespective mirror of a plurality of mirrors and comprises a reflectedimage of a first sample of a material reflected by the correspondingmirror, and wherein the plurality of mirrors define an ellipsoid; foreach first image: generating a respective region image for each regionin the first image by extracting the reflected image corresponding tothe region from the first image, wherein each region image comprises arespective plurality of region image pixels, and palettizing each of theregion images; and providing each palettized image to a computergraphics (CG) rendering engine for use in shading a CG representation ofthe material.

Other embodiments of this aspect include corresponding computer systems,apparatus, and computer programs recorded on one or more computerstorage devices, each configured to perform the actions of the methods.

A system of one or more computers can be configured to performparticular operations or actions by virtue of having software, firmware,hardware, or a combination of these installed on the system that inoperation causes the system to perform the actions. One or more computerprograms can be configured to perform particular operations or actionsby virtue of including instructions that, when executed by dataprocessing apparatus, cause the apparatus to perform the actions.

These and other embodiments can each optionally include one or more ofthe following features. The method can further include obtaininggeometry calibration data and color calibration data for use incalibrating the plurality of first images. Generating the respectiveregion image for each region in the first image can include: extractingthe reflected image corresponding to the region from the first imageusing the geometry calibration data; and adjusting the color of thereflected image using the color calibration data to generate the regionimage. The method can further include for each region image pixel:dividing the ellipsoid defined by the plurality of mirrors into a firstnumber of sectors, wherein a ray reflected by the material has an equalprobability of landing in each of the sectors, dividing each of thesectors into a second number of pieces, wherein a ray reflected by thematerial has an equal probability of landing in each of the pieces, andgenerating a table having a plurality of cells, wherein each of thecells in the table stores data identifying a center of a respectivepiece of the ellipsoid. The method can further include providing thetables for each region image pixel to a rendering engine for use indetermining effects of indirect lighting on the CG representation of thematerial. Dividing the ellipsoid defined by the plurality of mirrorsinto the first number of sectors can include iteratively accumulatinglocal probabilities of subdivisions of a surface of the ellipsoid. Thelocal probability of each subdivision can be a local brightness of thesubdivision divided by an average brightness of the surface of theellipsoid. Dividing each of the sectors into the second number of piecescan include iteratively accumulating local probabilities of subdivisionsof the sector. The method can further include obtaining a plurality ofsecond images, wherein each second image is a direct image of a second,larger sample of the material reflected by the corresponding mirror, andwherein each second image comprises a respective plurality of secondimage pixels; determining a respective most similar region image pixelfor each second image pixel; and storing a mapping that associates eachsecond image pixel with the corresponding most similar region imagepixel for the second image pixel. Each second image can be taken at arespective angle, and wherein each of the respective angles correspondsto an angle at which a respective one of the plurality of mirrorsreflects the first sample of the material. Determining a respective mostsimilar region image pixel for each second image pixel can include:determining a respective signature for each region image pixel and eachsecond image pixel; and selecting the most similar region image pixelsbased on the signatures. Determining the respective signature for eachregion image pixel and each second image pixel can include: computing aheight of the pixel and heights of a pre-determined number of neighborsof the pixel; and computing the signature for the pixel based on theheights. Determining the respective signature for each region imagepixel and each second image pixel can include computing the signaturefor the pixel based on a color matching. Selecting the most similarregion image pixels based on the signatures can include selecting aregion image pixel having a signature that has a smallest distance fromthe signature for the second image pixel as the most similar regionimage pixel from the second image pixel.

Particular embodiments of the subject matter described in thisspecification can be implemented so as to realize one or more of thefollowing advantages. A CG representation of a material can beeffectively shaded without obtaining multiple high-resolution images ofa large sample of the physical materials. Representations of materialshaving complicated and varying textures can be effectively shaded.Representations of materials can be effectively shaded using less dataand in a shorter amount of time.

In general, another innovative aspect of the subject matter described inthis specification can be embodied in methods that include the actionsof obtaining data describing a physical material, wherein the datadescribing the physical material includes a plurality of palettizedimages of a first sample of the physical material, wherein each of thepalettized images comprises a respective reflected image of a firstsample of the physical material reflected by a respective mirror of aplurality of mirrors; receiving a shading request to shade a particularpoint in a computer graphics (CG) representation of the physicalmaterial from a rendering engine, wherein the request identifies amapping position of the particular point, a view direction at themapping position, and a light direction at the mapping position;calculating a direct lighting color at the mapping position using theplurality of palettized images; calculating an indirect lighting colorat the mapping position using the data describing the physical material;generating a final color at the mapping position by combining the directlighting color and the indirect lighting color; and providing the finalcolor to the rendering engine for use in rendering the CG representationof the physical material.

Other embodiments of this aspect include corresponding computer systems,apparatus, and computer programs recorded on one or more computerstorage devices, each configured to perform the actions of the methods.

A system of one or more computers can be configured to performparticular operations or actions by virtue of having software, firmware,hardware, or a combination of these installed on the system that inoperation causes the system to perform the actions. One or more computerprograms can be configured to perform particular operations or actionsby virtue of including instructions that, when executed by dataprocessing apparatus, cause the apparatus to perform the actions.

These and other embodiments can each optionally include one or more ofthe following features. Positions of the plurality of mirrors can definea hemisphere. The method can further include generating a Voronoidiagram of a hemisphere defined by positions of a plurality of mirrorsthat each reflect a view of a material sample positioned above theplurality of mirrors from a different perspective; generating atwo-dimensional table containing a plurality of cells, wherein each ofthe cells is mapped to the hemisphere by a respective horizontal andvertical angle pair; and for each of the cells: constructing a circleover a surface of the ellipsoid at the horizontal and vertical anglepair corresponding to the cell, and storing a plurality of (position,weight) pairs as data corresponding to the cell, comprising: randomlylocating a pre-determined number of points within the circle, for eachof the points, determining a respective closest mirror for each of thepoints, for each of the mirrors, determining a count of points that havethe mirror as the closest mirror for the point, and determining arespective (position, weight) pair for each of the mirrors, wherein theposition identifies the mirror and the weight is determined by dividingthe count of points for the mirror by the pre-determined number.

Calculating the direct lighting color at the mapping position using theplurality of palettized images can include: identifying a first cell inthe two-dimensional table corresponding to the view direction;identifying a second cell in the two-dimensional table corresponding tothe light direction; determining a first contributing palettized imageand a second contributing palettized image using the (position, weight)pairs stored in the first cell and the second cell; extracting a firstpixel from the first contributing palettized image and a second pixelfrom the second contributing palettized image; and determining thedirect lighting color using the extracted pixels and the weights for thefirst and second cells. Extracting a pixel from each of the contributingpalettized images can include extracting the pixels by translatingcoordinates of the mapping position to a location in each contributingpalettized image. Determining the direct lighting color using theextracted pixels and the weights can include: determining a color of thefirst pixel and a color of the second pixel; weighting the color of thefirst pixel based on the weights in the (position, weight) pairs used toselect the first contributing palettized image; weighting the color ofthe second pixel based on the weights in the (position, weight) pairsused to select the second contributing palettized image; and summing theweighted colors to determine the direct lighting color. Generating theVoronoi diagram can include identifying a closest mirror for each pointin the ellipsoid, wherein the closest mirror is the mirror having ashortest distance from the point to the center of the mirror. Generatingthe Voronoi diagram can further include assigning each point that sharesa same closest mirror to a same zone in the Voronoi diagram.Constructing the circle over the surface can include selecting, fromeach possible circle covering at least two zones in the Voronoi diagram,the circle having the smallest radius. The data describing the physicalmaterial can include a K×M table for a first pixel in a first regionimage, wherein the first region image corresponds to the received viewdirection, wherein the first pixel corresponds to the received mappingposition, and wherein each cell of the table contains a position of acenter of a respective piece of an ellipsoid defined by the plurality ofmirrors.

Calculating the indirect lighting color at the mapping position usingthe data describing the physical material can include: determining afirst indirect lighting color at the mapping position, comprising:generating a first non-integer random number selected from a range ofzero to K; generating a second non-integer random number selected from arange of zero to M; indexing the table using the first random number andthe second random number to identify cells that bound the first randomnumber and the second random number; identifying positions contained inthe identified cells; combining the positions to generate a finalposition; and tracing a ray in the direction defined by the finalposition to determine the first indirect lighting color; and calculatingthe indirect lighting color at the mapping position based at least inpart on the first indirect lighting color. Calculating the indirectlighting color at the mapping position based at least in part on thefirst indirect lighting color can include using the first indirectlighting color as the indirect lighting color. Calculating the indirectlighting color at the mapping position based at least in part on thefirst indirect lighting color can include: calculating one or more otherindirect lighting colors; and combining the one or more other indirectlighting colors with the first indirect lighting color to generate afinal indirect lighting color.

The details of one or more embodiments of the subject matter of thisspecification are set forth in the accompanying drawings and thedescription below. Other features, aspects, and advantages of thesubject matter will become apparent from the description, the drawings,and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a high-level illustration of an example system for shading acomputer graphic (CG) representation of a physical material.

FIG. 2A is a diagram of an example material sample scanner.

FIG. 2B illustrates an example configuration of components within amaterial sample scanner.

FIG. 3 is a diagram of the bottom of a light source-camera assembly.

FIG. 4 shows a view of a mirror assembly from above.

FIG. 5 is an example mirror image generated by a material samplescanner.

FIG. 6 is a flow diagram of an example technique for generatingpalettized images for use in determining the direct lighting for a CGrepresentation of material.

FIG. 7 is a flow diagram of an example technique for generating datastructures for use in determining the effects of indirect lighting for aCG representation of a material.

FIG. 8 is a flow diagram of an example technique for calibrating thegeometry and color of images produced by a material sample scanner.

FIG. 9 is a flow diagram of an example technique for generating amapping between pixels in direct images and pixels in mirror images.

FIG. 10 is a flow diagram of an example technique for calculating thefinal color at a given mapping position.

FIG. 11A is a flow diagram of an example technique for determining theeffects of direct lighting at a given mapping position.

FIG. 11B shows an example Voronoi diagram.

FIG. 12 is a flow diagram of an example technique for determining theeffects of indirect lighting at a given mapping position.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION

FIG. 1 is a high-level illustration of an example system 100 for shadinga computer graphic (CG) representation of a physical material, e.g.,wood, fabric, leather, or metal, using a physical sample of thematerial.

The system 100 includes a rendering engine 106. The rendering engine 106renders images or animations, e.g., using conventional techniques.Generally, the rendering engine 106 generates images or animations froma prepared scene, e.g., based on models or other rendering criteria. Aspart of the rendering process and in order to account for the effects ofthe desired lighting conditions of the rendered scene on the CGrepresentations of physical materials, i.e., in order to accuratelydepict an image of a physical material in a three-dimensional model, therendering engine 106 may need to obtain shading information for the CGrepresentations from a shading module 108. The shading module 108 maybe, e.g., a plug-in software component for the rendering engine 106.

The shading module 108 receives a request for shading information fromthe rendering engine 106 that identifies the material to be shaded, themapping position that is to be shaded, i.e., a position in a UV mappingof the three-dimensional model of the image, the view direction for themapping position and the light direction at the mapping position. Themapping position may be expressed in, for example, UV coordinates. Inresponse to the request, the shading module 108 determines the finalcolor at the mapping position using data obtained from a materialbuilder system 104 and provides the final color to the rendering engine106 for rendering. In order to determine the final color at the mappingposition, the shading module 108 determines the effects of direct andindirect lighting at the position. Direct lighting is lighting providedfrom a light source without reflection from other surfaces. Indirectlighting is lighting provided by reflection of light from othersurfaces, i.e., a reflection of light provided from a direct lightsource from surfaces surrounding an object in a scene. Determining thefinal color at a given mapping position is described in more detailbelow with reference to FIG. 10.

The material builder system 104 can be implemented as computer programinstructions that execute on one or more data processing apparatus(e.g., personal computers, servers, tablet computers, smart phones,etc.) in one or more geographic locations. The material builder system104 receives images of a sample of a physical material generated by amaterial sample scanner 102 and generates data structures for use byshading modules, e.g., the shading module 108, in shading CGrepresentations of the material. Generating data for use in determiningthe effects of direct lighting on the shading a CG representation of thematerial under direct lighting is described below with reference to FIG.6. Generating data for use in determining the effects of indirectlighting on the shading of the CG representation of the material isdescribed below with reference to FIG. 7.

The material sample scanner 102 is an apparatus that generates images ofthe physical sample of the given material and provides them to thematerial builder system 104. Each image generated by the material samplescanner 102 includes multiple images of the sample at varying view andlighting directions. An example of a material sample scanner isdescribed below with reference to FIG. 2.

FIG. 2A is a diagram of an example material sample scanner 200. Thematerial sample scanner 200 is an apparatus that generates images of asample of material 250. By way of illustration, the material can be apiece of fabric, wood, leather, fur, carpet, metal, glass, plastic, acombination of these, or other materials. The dimensions of the sample250 can be, for example, approximately one inch by one inch. Othersample sizes are possible. Generally, the sample 250 will be a smallportion of a material that is to be shaded during rendering.

The scanner 200 includes a light source-camera assembly 240. The lightsource-camera assembly 240 includes a light source 202 and a camera 208.The light source 202 includes a lens that emits light directed at amirror 210, which reflects the light toward a mirror assembly 215.

The mirror assembly 215 includes a set of planar mirrors 204. Themirrors 204 are arranged so that they define an ellipsoid. That is, themirrors 204 are positioned so that the reflective surfaces of themirrors approximate a portion of an outer surface of an ellipsoid.Generally, the dimensions of the reflective surfaces of the mirrors arelarger than those of the sample 250. For example, if the dimensions ofthe sample are one inch by one inch, each mirror may be two inches bytwo inches.

The light source 202 is movable to directly illuminate each of themirrors 204. That is, the light source 202 is movable radially and theangle of the light source 202, the angle of the mirror 210, or both maybe adjustable in order for, at some combination of radial position ofthe light source 202 and angles of the light source 202 and the mirror210, the reflective surface of each of the mirrors to be directlyilluminated by light emitted by the lens of the light source andreflected by the mirror 210. In the illustrated example of FIG. 2, forinstance, the light source 202 is positioned such that an example lightray 225 emitted by the light source 202 is reflected by the mirror 210and directly intersects the reflective surface of one of the planarmirrors 204. In order for the light source 202 to be movable toilluminate each of the mirrors, the light source 202 can be mounted on arotating disc 220 and on a track that allows the light source 202 totraverse along the radius of the disc. The light source may be, e.g., acollimated light source, i.e., a light source that produces collimatedlight rays, i.e., light rays that are approximately parallel to oneanother.

The mirror assembly 215 also includes a sample support 206. The samplesupport 206 is configured to suspend the sample 250 between the set ofmirrors 204 and the light source 202 within the scanner 200. Inparticular, the sample support 206 is configured to suspend the sampleso that the sample is facing away from the light source 202 and thecenter of the sample is approximately at one focal point of an ellipse299 defined by the mirrors 204, i.e., the ellipse 299 that is formed bytaking a cross section of the ellipsoid through its center and is alongone of its semi-axes. By positioning the mirrors 204 and the materialsample 250 in this configuration, each of the mirrors 204 will reflectan image of the sample at a respective angle when the light source 202is directly illuminating any one of the mirrors 204. In someimplementations, the sample support 206 is further configured to allowthe sample to be rotated along one or more axes.

The camera 208 is positioned proximate to the light source 202. Forexample, the camera 208 may be positioned approximately above the centerof the sample. In particular, the camera 208 may be positionedapproximately at the other focal point of the ellipse 299. Thepositioning of the camera 208 relative to the set of mirrors 204 and thesample 250 is described in more detail below with reference to FIG. 2B.

In some implementations, the camera 208 is configured to capture animage of the mirrors 204 in response to a request, e.g., a requestreceived from a material builder system, e.g., the material buildersystem 104 of FIG. 1. In particular, the camera 208 can capture arespective image of the mirrors 204 when the light source 202 ispositioned to directly illuminate each of the mirrors. For example, ifthere are 40 positions and 40 mirrors, the camera 208 can be configuredto capture 40 images, each of which includes 40 reflected images of thesample with the light source positioned to directly illuminate arespective one of the mirrors. A reflected image of the sample 250 is animage of one of the mirrors 204 while the mirror 204 is reflecting animage of the sample 250 supported by the sample support 206. While ascanner 200 with 40 mirrors is used as an example, any number of mirrorsand, consequently, images is possible.

Once the images of the mirrors have been captured, the images can beprovided to the material builder system for processing. In someimplementations, prior to being processed by the material buildersystem, the images are converted to a particular format, e.g., theOpenEXR format. In other implementations, the material builder systemprocesses the images in the format in which they are captured by thecamera 204.

FIG. 2B illustrates an example configuration of components within thematerial sample scanner 200 of FIG. 2A. An ellipse 299 is shown that isdefined by the set of mirrors 204 of FIG. A. The material sample 250 ispositioned at the first focal point of the ellipse 299, i.e., the focalpoint closest to the set of mirrors 204. The camera 208 is positioned atthe other focal point of the ellipse 299. As an example, the major axis299 a of the ellipse 299, i.e., the axis that runs through the sample250 and the camera 208, may be approximately 120 centimeters in lengthand the minor axis 299 b may be approximately 66 centimeters in length.In this example, the distance between the material sample 250 and thecamera 208 is approximately 50 centimeters. Other dimensions arepossible, however.

FIG. 3 is a diagram of the bottom of the light source-camera assembly240 of FIG. 2A. The light source-camera assembly 240 includes a lightsource 202 that is positioned to emit light rays that are reflected offof a mirror 210 towards a set of mirrors, e.g., the set of mirrors 204of FIG. 2A. The light source 202 is mounted on a rotating disc 220 inorder to allow the light source 202 to be movable radially. As describedabove, the angle of the light source 202, of the mirror 210, or both maybe adjustable. The light source-camera assembly 240 includes an aperture275. A camera, e.g., the camera 208 of FIG. 2A, may be positioned overthe aperture.

FIG. 4 shows a view of the mirror assembly 215 of FIG. 2A from above.The mirror assembly 215 includes a set of planar mirrors 204. Asdescribed above, the mirrors in the set of planar mirrors 204 arepositioned so that the reflective surfaces of the mirrors approximate aportion of an outer surface of an ellipsoid. The mirror assembly 215also includes a sample support 206. The sample support 206 is configuredto suspend a sample above the set of planar mirrors 204 using supportarms 292. While not visible in the view from above, the sample issuspended on the underside of the sample support 206. The support arms292 are positioned so that they do not obstruct the view of any of themirrors in the set of planar mirrors 204 in images taken from a camerapositioned above the mirror assembly 215.

FIG. 5 is an example mirror image 500 generated by a material samplescanner, e.g., the material sample scanner 200 of FIG. 2A. The mirrorimage 500 includes a set of regions, e.g., the region 502, with each ofthe regions corresponding to an area of the image 500 that contains thereflection of a respective mirror in a set of planar mirrors, e.g., theset of mirrors 204 of FIG. 2A, and an image of the top side of a samplesupport 504. Each region includes a respective reflected image of asample of the material that is to be shaded. The mirror image 500 is animage that is generated while a light source, e.g., the light source 202of FIG. 2A, was directly illuminating one of the mirrors in the set ofmirrors and the sample was suspended by the sample support. For example,when the mirror image 500 was taken, the light source may have beendirectly illuminating the mirror that corresponds to the region 502 inthe mirror image 500. In this case, the region 502 will include areflected image of the sample as reflected by the corresponding mirrorwhile being directly illuminated by the light source.

FIG. 6 is a flow diagram of an example technique 600 for generatingpalettized images for use in determining the effects of direct lightingfor a CG representation of material. For convenience, the technique 600will be described as being performed by a system of one or more dataprocessing apparatus located in one or more locations. For example, amaterial builder system, e.g., the material builder system 104 of FIG.1, appropriately programmed, can perform the technique 600.

The system calibrates 602 the color and, optionally, the geometry of theimages produced by a material sample scanner, e.g., the material samplescanner 102 of FIG. 1. An example technique for calibrating the geometryand the color will be described below with reference to FIG. 8. As aresult of the calibration process, the system generates colorcalibration data that identifies a color transformation to be applied tothe reflected images in the images produced by the material samplescanner and, optionally, geometry calibration data that identifieslocations of the reflected images in the images produced by the materialsample scanner.

The system obtains 604 a set of mirror images generated by the materialsample scanner. Each mirror image, e.g., mirror image 500 of FIG. 5,includes a set of regions, with each of the regions corresponding to arespective mirror in a set of mirrors, e.g., the set of mirrors 204 ofFIG. 2A. Each region, e.g., region 502 of FIG. 5, includes a respectivereflected image of a sample of the material that is to be shaded.Generally, the set of mirror images will include the same number ofmirror images as the number of mirrors in the set of mirrors, with theset of mirror images including images taken while the light source isdirectly illuminating different mirrors in the set of mirrors.

For each mirror image, the system generates 606 a respective regionimage for each region in the mirror image using the color calibrationdata and, optionally, the geometry calibration data. The systemgenerates the region images by extracting the reflected image from eachregion. In particular, the system extracts the content of each of theregions in the mirror image using the locations identified in thegeometry calibration data or, if no geometry calibration is performed,by identifying the locations of the regions directly from the mirrorimage.

As part of generating the region images, the system generates datadefining a hemisphere using the locations of the mirrors. That is, thesystem uses data identifying the locations of the mirrors to determine arespective angle of the center of each mirror with respect to either thematerial sample or to the light source. The system then uses thoseangles to define a hemisphere having a predetermined radius, e.g., aradius of one.

Optionally, the system converts each region into rectangular form. Thesystem can then adjust the color of each pixel in each region based onthe color calibration data in order to generate the region images.

The system palettizes 608 the region images and stores 610 thepalettized images. Generally, palettizing an image reduces the colorsused in the image to a predetermined number of colors. In particular,the system replaces the color of each pixel with a color index thatpoints to a cell in a palette table. The palette table contains a listof the colors used in the picture. The system can palletize the regionimages using, e.g., conventional palettization techniques. The systemindexes the stored palettized image by (light, camera) pair, where the“light” value for each palettized image identifies the mirror that wasbeing directly illuminated while the palettized image was taken, and the“camera” value for each image identifies the mirror over which thecamera was positioned while the palettized image was taken. The systemcan generate the identifiers for the mirrors by assigning each mirror arespective integer ranging from one to the total number of mirrors.

The stored palettized images can be provided to a shading module, e.g.,the shading module 108 of FIG. 1, for use in determining the directlighting for a CG representation of the material. The system can providethe palettized images in association with the corresponding (light,camera) pair for each image.

FIG. 7 is a flow diagram of an example technique 700 for generating datastructures for use in determining the effects of indirect lighting for aCG representation of a material. For convenience, the technique 700 willbe described as being performed by a system of one or more dataprocessing apparatus located in one or more locations. For example, amaterial builder system, e.g., the material builder system 104 of FIG.1, appropriately programmed, can perform the technique 700.

In some implementations, the technique 700 is performed for each pixelin each region image generated from mirror images obtained from thematerial sample scanner.

The system divides 702 the hemisphere defined by the set of mirrors intoa first number of sectors. In particular, the system divides thehemisphere so that a ray reflected by the material has an equalprobability of landing in each of the sectors. The system can constructthese equal probability sectors based on local probabilities, where eachlocal probability is a local brightness divided by the averagebrightness of the entire hemisphere. The brightness of any givensubdivision of an image can be measured as, e.g., the average value ofthe red (R), green (G), and blue (B) colors in the subdivision, i.e.,(R+G+B)/3.

In order to divide the hemisphere into sectors, the system iterativelyaccumulates subdivisions of the hemisphere surface. That is, the systemselects small subdivisions of the hemisphere surface, e.g., with eachsubdivision being 1/10000 of the entire hemisphere surface. For example,the system may select the subdivisions by traversing the hemispheresurface along each axis using a pre-determined step size, e.g., onedegree.

The system sums the probability of each successive subdivision until thesummed probabilities sum to 1/K, where K is the desired first number ofsectors. The system then defines the first sector as the aggregate ofthe subdivisions included in the sum and continues the process untileach sector is defined.

The system divides 704 each of the sectors into a second number ofpieces. In particular, the system divides each sector so that a rayreflected by the material has an equal probability of landing in each ofthe pieces. The system can divide each sector into the second number ofpieces using, e.g., the same technique described above for dividing thehemisphere.

The system generates 706 a data structure that stores data identifyingthe center of each of the pieces. For example, if there are K sectorseach divided into M pieces, the system can generate a K×M table, withthe data in each entry of the table being the position of the center ofeach of the pieces.

Once the technique 700 has been performed for each pixel in each regionimage, the system can provide the data structure to a shading module,e.g., the shading module 108 of FIG. 1, for use in determining theindirect lighting for a CG representation of the material.

In addition to the data identifying the center of each of the pieces ofthe hemisphere for each of the pixels and the palettized region images,the system can also provide to the shading module informationidentifying the dimensions of the physical sample of the material, thenumber of regions in each mirror image, the locations of each of theregions in the mirror image, and the data identifying the hemispheredefined by the mirrors.

FIG. 8 is a flow diagram of an example technique 800 for calibrating thegeometry and color of images produced by a material sample scanner(e.g., material scanner 102). For convenience, the technique 800 will bedescribed as being performed by a system of one or more data processingapparatus located in one or more locations. For example, a materialbuilder system, e.g., the material builder system 104 of FIG. 1,appropriately programmed, can perform the technique 800.

The system obtains 802 a mirror image generated by the material samplescanner (e.g., material scanner 102) using a sample material having aspecific, pre-determined pattern. For example, the pattern may be acheckerboard pattern. Other patterns are possible.

The system identifies 804 the initial locations of each of the regionsin the mirror image. For example, the system can analyze the mirrorimage to identify each edge of each region in the mirror image anddetermine each intersection of two identified edges using edge detectiontechniques, for example. Each point of intersection can be identified asa corner of a region and the location of the regions can be defined bythe identified edges and corners.

In some implementations, the system adjusts 806 the initial locationsbased on the pre-determined pattern on the material. In particular, foreach region, the system performs a low-frequency Fourier analysis andadjusts the initial locations based on the result of the Fourieranalyses. The system determines the average phase and frequency of thefour largest regions in a given mirror image and adjusts the locationsof each initial corner in order to equalize the phase of their region tothe average phase and frequency for the four largest regions. The systemstores the adjusted location data as geometry calibration data thatidentifies the locations of reflected images in the images produced bythe material sample scanner. In some implementations, the system doesnot generate geometry calibration data but instead identifies initiallocations of regions in each mirror image processed by the system, e.g.,by identifying the edges and intersections as described above.

The system obtains 808 a mirror image generated by the material samplescanner of a white material having a pure diffuse bidirectionalreflectance distribution function (BRDF).

The system determines 810 the unit sphere BRDF from the mirror imagesand stores the data as color calibration data that identifies a colortransformation to be applied to the color of the reflected images. Thatis, the system can use the color calibration data to normalize the colorof images taken by the material sample scanner before they are used by ashading module.

While the above description describes generating data for use by ashading module in shading a CG representation of a physical material,the above data is generated based on mirror images of a small sample ofthe material. In some circumstances, it may be beneficial to obtainso-called direct images of a large sample of the material and provide amapping to the shading module that identifies, for each pixel in one ofthe direct images of the large sample, the most similar pixel in any ofthe mirror images to the pixel. For example, when the physical sampleincludes a pattern that is either non-repeating or a pattern thatrepeats but that cannot be entirely captured in a small sample of thematerial, the shading module may need to use the provided mapping to mapthe pixels of the large sample to the most similar pixels in the mirrorimages. Generally, the surface area of the large sample will beapproximately ten times that of the smaller sample used to generate themirror images. Generating the mapping is described below with referenceto FIG. 9.

FIG. 9 is a flow diagram of an example technique 900 for generating amapping between pixels in direct images and pixels in mirror images. Forconvenience, the technique 900 will be described as being performed by asystem of one or more data processing apparatus located in one or morelocations. For example, a material builder system, e.g., the materialbuilder system 104 of FIG. 1, appropriately programmed, can perform thetechnique 900.

The system obtains 902 a set of mirror images of a small sample of aphysical material from a material sample scanner, e.g., the materialsample scanner 102 of FIG. 1.

The system obtains 904 a set of direct images of a large sample of thephysical material. Generally, each direct image is taken at an anglethat corresponds to the angle at which one of the mirrors in thematerial sample scanner reflects the image of the small sample. Forexample, the set of direct images may include four images that are eachcaptured at a respective angle that corresponds to a respective angle ofone of the four mirrors in the set of mirrors 204 that appear closest tothe sample in the mirror images, e.g., the mirrors corresponding to theregions 506, 508, 510, and 512 of FIG. 5.

The system determines 906 a signature for each pixel in each of thedirect images. Each signature is a set of values that represents thepixel. For example, the signatures may be n-dimensional vectors, where nis a pre-determined integer. The system may compute the signature for apixel in any of a variety of ways.

In some implementations, the system may compute the signature for apixel by computing the height of the pixel and the height of apre-determined number, e.g., eight, neighbors of the pixel in the image.The signature may then be computed based at least in part on theheights. For example, the signature may be a vector of the heightvalues. Generally, because the surface of the physical material is notflat, the value of the height of a given pixel is the value of thevariation of the surface of the physical material in the verticaldirection at the point that the pixel represents.

The system computes the heights for the pixel and the neighboring pixelsfrom a height map for the material. In order to generate the height map,the system generates a normal field from four images of the material.That is, the system can solve two systems of linear equations, eachcontaining three of the four images, to generate the height for eachpoint. The systems of linear equations can be generated by assuming thatthe measured brightness at a point is proportional to the dot productbetween the surface normal at the point and the light direction at thepoint. The system can combine the solutions of the two systems togenerate the height at the point, e.g., using some of the components ofthe solution of the first system and the other components of the normalof the solution of the second system.

From the normal field, the system iteratively determines the height map.In particular, the initial iteration assumes zero height for all thepixels. For each pixel, the system calculates the normal based expecteddifference to the neighbor pixels and compares it to the difference inthe normal field. The system subtracts the error from the current heightto generate the final height for the iteration. Once the height mapconverges to a relatively persistent state between iterations, theconvergent height map is used as the final height map to determine theheights of the pixels for the signature.

In other implementations, the system may generate the signature for apixel based on a color matching. In order to generate a color-matchedsignature for a pixel, the system identifies the pixels surrounding thepixel of interest in each of the four images. For example, for eachimage, the system can generate a three by three grid of pixels with thepixel of interest being at the center of the grid. The system thengenerates the signature for the pixel based on the RGB values for eachof the pixels in each of the grids. For example, the signature may be anordered list of all of the RGB values.

The system then determines 908 the most similar pixel from any of theregion images for each pixel in each of the direct images. Generally,the most similar region image pixel to any given direct image pixel isthe mirror image pixel having a signature that has the smallest distancebetween it and the signature for the direct image pixel. In particular,when the signatures are represented by n-dimensional vectors, thedistance d between a signature A and a signature B satisfies:d=(A ₁ −B ₁)²+(A ₂ −B ₂)²+ . . . +(A _(n) −B _(n))².

The system stores 910 a mapping that associates each pixel in the directimages with the most similar pixel to the pixel in one of the mirrorimages. For example, the system can store data associating thecoordinates of the pixel in the direct image with the coordinates of themost similar pixel in the mirror image to which it belongs.

FIG. 10 is a flow diagram of an example technique 1000 for calculatingthe final color at a given mapping position. For convenience, thetechnique 1000 will be described as being performed by a system of oneor more data processing apparatus located in one or more locations. Forexample, a shading module, e.g., the shading module 108 of FIG. 1,appropriately programmed, can perform the technique 1000.

The system obtains data describing a physical material (step 1002) froma material builder system, e.g., the material builder system 104 ofFIG. 1. The data includes data for use in calculating the effects ofdirect and indirect lighting at particular points on CG representationsof the physical material. The system can obtain the data at varioustimes, e.g., in response to receiving a request to shade the CGrepresentation of the physical material or before receiving the request.Depending on the physical material, the data may include dataassociating the coordinates of each pixel in each of a set of directimages of a large sample of the physical material with data identifyingthe most similar pixel in any of the mirror images of a small sample ofthe physical material.

The system receives a shading request from a rendering engine (step1004), e.g., the rendering engine 106 of FIG. 1. The shading requestidentifies the material to be shaded, the mapping position that is to beshaded, i.e., a position in a UV mapping of the three-dimensional modelof the image, the view direction for the mapping position and the lightdirection at the mapping position.

If the data obtained by the system included data associating thecoordinates of each pixel in each of a set of direct images of a largesample of the physical material with data identifying the most similarpixel in any of the mirror images of a small sample of the physicalmaterial, the system can convert the mapping position identified in therequest into a point in the mirror images of the small sample using thedata. The system can then use that position in calculating the finalcolor.

The system calculates the color under direct lighting at the mappingposition identified in the request using the data describing thephysical material (step 1006). An example technique for calculating thecolor under direct lighting is described below with reference to FIG.11.

The system calculates the color under indirect lighting at the mappingposition using the data describing the physical material (step 1008). Anexample technique for calculating the color under indirect lighting isdescribed below with reference to FIG. 12.

The system combines the colors to generate the final color at themapping position (step 1010). For example, the system can sum the colorunder direct lighting and the color under indirect lighting to generatethe final color.

The system provides the final color to the rendering engine for use inrendering the CG representation of the physical material (step 1012).

FIG. 11A is a flow diagram of an example technique 1100 for determiningthe effects of direct lighting at a given mapping position. Forconvenience, the technique 1100 will be described as being performed bya system of one or more data processing apparatus located in one or morelocations. For example, a shading module, e.g., the shading module 108of FIG. 1, appropriately programmed, can perform the technique 1100.

The system constructs 1102 a Voronoi diagram over a surface defined bythe angles of the mirrors in the material sample scanner. That is, foreach point in the surface, the system identifies the closest mirror,where the distance from a point to a mirror is defined by the distancefrom the point to the center of the mirror. All of the points that sharethe same closest mirror collectively form a zone in the Voronoi diagram.The surface can be, e.g., the portion of the ellipsoid defined by thepositions of the mirrors as described with reference to FIGS. 2A and 2B.Alternatively, the surface can be the hemisphere defined by the anglesof the mirrors.

FIG. 11B shows an example Voronoi diagram 1150. The example Voronoidiagram 1150 was constructed over a hemisphere defined by the angles ofthe mirrors in a material sample scanner. The diagram 1150 includes anumber of zones, e.g., zone 1152 and zone 1154, that each includes allof the points that share the same closest mirror in the set of mirrors.

Returning to the description of FIG. 11A, the system generates 1104 atable that is mapped to the surface by horizontal and vertical angle.That is, each cell in the table represents a respective area of thesurface having a respective angular width and height. For example, ifthe table is a 1025×256 table, each cell in the table represents arespective area having a 0.35 degree width and a 0.35 degree height.

For each cell of the table, the system constructs 1106 a circle centeredat the center of the area represented by the cell over the surface andidentifies the intersections of the circle with the zones of the Voronoidiagram. The system constructs each circle such that the circle has thesmallest possible radius that covers at least two zones in the Voronoidiagram for any direction, i.e., any line drawn through the center ofcircle at an arbitrary direction must cross two or more zones of theVoronoi diagram before it exits the circle.

The system stores 1108 data in each cell of the table. In particular, ineach cell, the system stores one or more (position, weight) pairs. Inorder to identify the (position, weight) pairs for a given cell, thesystem randomly locates a pre-determined number N of random pointswithin the circle for the cell. For example, N may be 200, 500, 1000, or2500. For each point, the system determines the closest mirror, anddetermines, for each of the mirrors, how many points have that mirror asthe closest mirror for the point. The system then stores a respective(position, weight) pair for each mirror, where the position valueidentifies the mirror and the weight is computed by dividing the numberof points that have that mirror as the closest mirror by the totalnumber of random points N. The system then stores each of the (position,weight) pairs in the corresponding cell in the table.

The system receives 1110 data that identifies the material to be shaded,the mapping position that is to be shaded, i.e., a position in a UVmapping of the three-dimensional model of the image, the view directionfor the mapping position and the light direction at the mappingposition.

The system modifies 1112 the view direction and the light directions sothat they map to cells of the table. For example, if the directions areprovided to the system as (x,y,z) that have a range of [−1,1], thesystem may modify the x and y coordinates as follows: the system can add1 to each of the x and y coordinates to change their range to [0, 2] andthen divide each of the x and y coordinates by 2 to change the range to[0,1]. The system can then multiply x and y by the table width, i.e.,the number of columns in the table to change the range to [0, width].

The system identifies 1114 cells in the table using the view directionand the light direction. That is, the system identifies a first cellusing the view direction and a second cell using the light direction.The system can identify a cell from a set of coordinates by using the xcoordinate as the column index for the cell and the y coordinate as therow index for the cell.

The system identifies 1116 contributing palettized images and arespective weight for each contributing image using the content storedin the identified cells in the table. That is, each of the identifiedcells stores one or more (position, weight) pairs. The system computeseach possible (position1, position2) pair, where position1 is one of thepositions stored in the cell identified using the view direction, andposition2 is one of the positions stored in the cell identified by thelight direction. For each (position1, position2) pair, the systemcomputes a weight by multiplying the weight that is paired withposition1 by the weight that is paired with position2. The system thenmaps each (position1, position2) pair to the palettized image identifiedby the (light, camera) pair having values that match the (position1,position2) pair and uses the weight for the (position1, position2) pairas the weight for the palettized image.

The system selects 1118 a pixel from each contributing palettized image.The system can select the pixels from each image using the UVcoordinates received from the rendering engine, i.e., by translating thereceived UV coordinates to an image location and selecting the pixel atthat location in each contributing image.

The system determines 1120 the color under direct lighting at themapping position based on the weights for each contributing image. Thatis, the system multiplies the color of each pixel by the weight for thecorresponding image and then sums the weighted colors to determine thecolor under direct lighting at the position.

FIG. 12 is a flow diagram of an example technique for determining theeffects of indirect lighting at a given mapping position. Forconvenience, the technique 1200 will be described as being performed bya system of one or more data processing apparatus located in one or morelocations. For example, a shading module, e.g., the shading module 108of FIG. 1, appropriately programmed, can perform the technique 1200.

The system accesses 1202 the data identifying the center of each of thepieces of the hemisphere obtained from the material sample scanner. Thatis, the system accesses the K×M table that corresponds to the pixel andregion image that are identified by the position in the UV mapping andthe light direction specified in the request. In other words, the systemidentifies the region image that corresponds to the light directionspecified in the request, identifies the pixel in the identified imagethat corresponds to the position in the UV mapping, and accesses the K×Mtable that corresponds to the identified pixel.

The system generates 1204 two random numbers. The random numbers arenon-integer numbers, with the first number being selected from a rangeof zero to K and the second number being selected from a range of zeroto M.

The system indexes 1206 the table using the two random numbers toidentify the four table cells that bound the pair of numbers. Forexample, if the first number is 2.4 and the second number is 3.6, thefour cells that bound the pair of numbers will be the cells having theindices [2,3], [2,4], [3,3], and [3,4].

The system identifies 1208 the positions stored in the table cells thatbound the pair of numbers.

The system mixes 1210 the positions using bilinear interpolation togenerate a final position and then traces 1212 a ray from the mappingposition in the direction defined by the final position to determine thecolor for the ray. In order to determine the color for the ray, thesystem can send a request to the rendering engine identifying thedirection of the ray and the rendering engine can return the color thatresults from tracing the ray in that direction.

In some implementations, the system can repeat steps 1204 through 1212multiple times to generate multiple colors. The system can then averagethe colors generated by casting each ray to determine the final color atthe mapping position.

Embodiments of the subject matter and the operations described in thisspecification can be implemented in digital electronic circuitry, or incomputer software, firmware, or hardware, including the structuresdisclosed in this specification and their structural equivalents, or incombinations of one or more of them. Embodiments of the subject matterdescribed in this specification can be implemented as one or morecomputer programs, i.e., one or more modules of computer programinstructions, encoded on computer storage medium for execution by, or tocontrol the operation of, data processing apparatus. Alternatively or inaddition, the program instructions can be encoded on anartificially-generated propagated signal, e.g., a machine-generatedelectrical, optical, or electromagnetic signal, that is generated toencode information for transmission to suitable receiver apparatus forexecution by a data processing apparatus. A computer storage medium canbe, or be included in, a computer-readable storage device, acomputer-readable storage substrate, a random or serial access memoryarray or device, or a combination of one or more of them. Moreover,while a computer storage medium is not a propagated signal, a computerstorage medium can be a source or destination of computer programinstructions encoded in an artificially-generated propagated signal. Thecomputer storage medium can also be, or be included in, one or moreseparate physical components or media.

The operations described in this specification can be implemented asoperations performed by a data processing apparatus on data stored onone or more computer-readable storage devices or received from othersources. The term “data processing apparatus” encompasses all kinds ofapparatus, devices, and machines for processing data, including by wayof example a programmable processor, a computer, a system on a chip, ormultiple ones, or combinations, of the foregoing. The apparatus can alsoinclude, in addition to hardware, code that creates an executionenvironment for the computer program in question, e.g., code thatconstitutes processor firmware, a protocol stack, a database managementsystem, an operating system, a cross-platform runtime environment, avirtual machine, or a combination of one or more of them. The apparatusand execution environment can realize various different computing modelinfrastructures, e.g., web services, distributed computing and gridcomputing infrastructures.

A computer program (also known as a program, software, softwareapplication, script, or code) can be written in any form of programminglanguage, including compiled or interpreted languages, declarative orprocedural languages, and it can be deployed in any form, including as astand-alone program or as a module, component, subroutine, object, orother unit suitable for use in a computing environment. A computerprogram may, but need not, correspond to a file in a file system. Aprogram can be stored in a portion of a file that holds other programsor data, e.g., one or more scripts stored in a markup language document,in a single file dedicated to the program in question, or in multiplecoordinated files, e.g., files that store one or more modules,sub-programs, or portions of code. A computer program can be deployed tobe executed on one computer or on multiple computers that are located atone site or distributed across multiple sites and interconnected by acommunication network.

The processes and logic flows described in this specification can beperformed by one or more programmable processors executing one or morecomputer programs to perform actions by operating on input data andgenerating output. Processors suitable for the execution of a computerprogram include, by way of example, both general and special purposemicroprocessors, and any one or more processors of any kind of digitalcomputer. Generally, a processor will receive instructions and data froma read-only memory or a random access memory or both. The essentialelements of a computer are a processor for performing actions inaccordance with instructions and one or more memory devices for storinginstructions and data. Generally, a computer will also include, or beoperatively coupled to receive data from or transfer data to, or both,one or more mass storage devices for storing data. However, a computerneed not have such devices. Moreover, a computer can be embedded inanother device, e.g., a mobile telephone, a smart phone, a mobile audioor video player, a game console, a Global Positioning System (GPS)receiver, and a wearable computer device, to name just a few. Devicessuitable for storing computer program instructions and data include allforms of non-volatile memory, media and memory devices, including by wayof example semiconductor memory devices, magnetic disks, and the like.The processor and the memory can be supplemented by, or incorporated in,special purpose logic circuitry.

To provide for interaction with a user, embodiments of the subjectmatter described in this specification can be implemented on a computerhaving a display device for displaying information to the user and akeyboard and a pointing device, e.g., a mouse or a trackball, by whichthe user can provide input to the computer. Other kinds of devices canbe used to provide for interaction with a user as well; for example,feedback provided to the user can be any form of sensory feedback, e.g.,visual feedback, auditory feedback, or tactile feedback; and input fromthe user can be received in any form, including acoustic, speech, ortactile input and output.

While this specification contains many specific implementation details,these should not be construed as limitations on the scope of anyinventions or of what may be claimed, but rather as descriptions offeatures specific to particular embodiments of particular inventions.Certain features that are described in this specification in the contextof separate embodiments can also be implemented in combination in asingle embodiment. Conversely, various features that are described inthe context of a single embodiment can also be implemented in multipleembodiments separately or in any suitable subcombination. Moreover,although features may be described above as acting in certaincombinations and even initially claimed as such, one or more featuresfrom a claimed combination can in some cases be excised from thecombination, and the claimed combination may be directed to asubcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. In certain circumstances, multitasking and parallel processingmay be advantageous. Moreover, the separation of various systemcomponents in the embodiments described above should not be understoodas requiring such separation in all embodiments, and it should beunderstood that the described program components and systems cangenerally be integrated together in a single software product orpackaged into multiple software products.

Thus, particular embodiments of the subject matter have been described.Other embodiments are within the scope of the following claims. In somecases, the actions recited in the claims can be performed in a differentorder and still achieve desirable results. In addition, the processesdepicted in the accompanying figures do not necessarily require theparticular order shown, or sequential order, to achieve desirableresults. In certain implementations, multitasking and parallelprocessing may be advantageous.

What is claimed is:
 1. A method comprising: obtaining data describing aphysical material, wherein the data describing the physical materialincludes a plurality of palettized images of a first sample of thephysical material, wherein each of the palettized images comprises arespective reflected image of the first sample of the physical materialreflected by a respective mirror of a plurality of mirrors; receiving ashading request to shade a particular point in a representation of thephysical material, wherein the request identifies a mapping position ofthe particular point, a view direction at the mapping position, and alight direction at the mapping position; calculating, sing one or morecomputers, a direct lighting color at the mapping position using theplurality of palettized images; calculating, sing one or more computers,an indirect lighting color at the mapping position using the datadescribing the physical material; generating, using one or morecomputers, a final color at the mapping position using the directlighting color and the indirect lighting color; and providing the finalcolor to a rendering engine.
 2. The method of claim 1, wherein positionsof the plurality of mirrors define a hemisphere.
 3. The method of claim1, further comprising: generating a Voronoi diagram of a hemispheredefined by positions of the plurality of mirrors that each reflect aview of the material sample positioned above the plurality of mirrorsfrom a different perspective; generating a two-dimensional tablecontaining a plurality of cells, wherein each of the cells is mapped tothe hemisphere by a respective horizontal and vertical angle pair; andfor each of the cells: constructing a circle over a surface of anellipsoid at the horizontal and vertical angle pair corresponding to thecell, and storing a plurality of (position, weight) pairs as datacorresponding to the cell, comprising: randomly locating apre-determined number of points within the circle, for each of thepoints, determining a respective closest mirror, for each of themirrors, determining a count of points that have the mirror as theclosest mirror for the point, and determining a respective (position,weight) pair for each of the mirrors, wherein the position identifiesthe mirror and the weight is determined by dividing the count of pointsfor the mirror by the pre-determined number.
 4. The method of claim 3,wherein calculating the direct lighting color at the mapping positionusing the plurality of palettized images comprises: identifying a firstcell in the two-dimensional table corresponding to the view direction;identifying a second cell in the two-dimensional table corresponding tothe light direction; determining a first contributing palettized imageand a second contributing palettized image using the (position, weight)pairs stored in the first cell and the second cell; extracting a firstpixel from the first contributing palettized image and a second pixelfrom the second contributing palettized image; and determining thedirect lighting color using the extracted pixels and the weights for thefirst and second cells.
 5. The method of claim 4, wherein extracting apixel from each of the contributing palettized images comprisesextracting the pixels by translating coordinates of the mapping positionto a location in each contributing palettized image.
 6. The method ofclaim 4, wherein determining the direct lighting color using theextracted pixels and the weights comprises: determining a color of thefirst pixel and a color of the second pixel; weighting the color of thefirst pixel based on the weights in the (position, weight) pairs used toselect the first contributing palettized image; weighting the color ofthe second pixel based on the weights in the (position, weight) pairsused to select the second contributing palettized image; and summing theweighted colors to determine the direct lighting color.
 7. The method ofclaim 3, wherein generating the Voronoi diagram comprises identifying aclosest mirror for each point in the ellipsoid, wherein the closestmirror is the mirror having a shortest distance from the point to thecenter of the mirror.
 8. The method of claim 7, wherein generating theVoronoi diagram further comprises assigning each point that shares asame closest mirror to a same zone in the Voronoi diagram.
 9. The methodof claim 3, wherein constructing the circle over the surface comprisesselecting, from each possible circle covering at least two zones in theVoronoi diagram, the circle having the smallest radius.
 10. The methodof claim 1, wherein the data describing the physical material comprisesa K×M table for a first pixel in a first region image, wherein the firstregion image corresponds to the received view direction, wherein thefirst pixel corresponds to the received mapping position, and whereineach cell of the table contains a position of a center of a respectivepiece of an ellipsoid defined by the plurality of mirrors.
 11. Themethod of claim 10, wherein calculating the indirect lighting color atthe mapping position using the data describing the physical materialcomprises: determining a first indirect lighting color at the mappingposition, comprising: generating a first non-integer random numberselected from a range of zero to K; generating a second non-integerrandom number selected from a range of zero to M; indexing the tableusing the first random number and the second random number to identifycells that bound the first random number and the second random number;identifying positions contained in the identified cells; combining thepositions to generate a final position; and tracing a ray in thedirection defined by the final position to determine the first indirectlighting color; and calculating the indirect lighting color at themapping position based at least in part on the first indirect lightingcolor.
 12. The method of claim 11, wherein calculating the indirectlighting color at the mapping position based at least in part on thefirst indirect lighting color comprises using the first indirectlighting color as the indirect lighting color.
 13. The method of claim11, wherein calculating the indirect lighting color at the mappingposition based at least in part on the first indirect lighting colorcomprises: calculating one or more other indirect lighting colors; andcombining the one or more other indirect lighting colors with the firstindirect lighting color to generate a final indirect lighting color. 14.A system comprising one or more computers and one or more storagedevices storing instructions that when executed by the one or morecomputers cause the one or more computers to perform operationscomprising: obtaining data describing a physical material, wherein thedata describing the physical material includes a plurality of palettizedimages of a first sample of the physical material, wherein each of thepalettized images comprises a respective reflected image of the firstsample of the physical material reflected by a respective mirror of aplurality of mirrors; receiving a shading request to shade a particularpoint in a representation of the physical material, wherein the requestidentifies a mapping position of the particular point, a view directionat the mapping position, and a light direction at the mapping position;calculating a direct lighting color at the mapping position using theplurality of palettized images; calculating an indirect lighting colorat the mapping position using the data describing the physical material;generating a final color at the mapping position using the directlighting color and the indirect lighting color; and providing the finalcolor to a rendering engine.
 15. The system of claim 14, the operationsfurther comprising: generating a Voronoi diagram of a hemisphere definedby positions of the plurality of mirrors that each reflect a view of thematerial sample positioned above the plurality of mirrors from adifferent perspective; generating a two-dimensional table containing aplurality of cells, wherein each of the cells is mapped to thehemisphere by a respective horizontal and vertical angle pair; and foreach of the cells: constructing a circle over a surface of an ellipsoidat the horizontal and vertical angle pair corresponding to the cell, andstoring a plurality of (position, weight) pairs as data corresponding tothe cell, comprising: randomly locating a pre-determined number ofpoints within the circle, for each of the points, determining arespective closest mirror, for each of the mirrors, determining a countof points that have the mirror as the closest mirror for the point, anddetermining a respective (position, weight) pair for each of themirrors, wherein the position identifies the mirror and the weight isdetermined by dividing the count of points for the mirror by thepre-determined number.
 16. The system of claim 15, wherein calculatingthe direct lighting color at the mapping position using the plurality ofpalettized images comprises: identifying a first cell in thetwo-dimensional table corresponding to the view direction; identifying asecond cell in the two-dimensional table corresponding to the lightdirection; determining a first contributing palettized image and asecond contributing palettized image using the (position, weight) pairsstored in the first cell and the second cell; extracting a first pixelfrom the first contributing palettized image and a second pixel from thesecond contributing palettized image; and determining the directlighting color using the extracted pixels and the weights for the firstand second cells.
 17. The method of claim 16, wherein determining thedirect lighting color using the extracted pixels and the weightscomprises: determining a color of the first pixel and a color of thesecond pixel; weighting the color of the first pixel based on theweights in the (position, weight) pairs used to select the firstcontributing palettized image; weighting the color of the second pixelbased on the weights in the (position, weight) pairs used to select thesecond contributing palettized image; and summing the weighted colors todetermine the direct lighting color.
 18. The system of claim 14, whereinthe data describing the physical material comprises a K×M table for afirst pixel in a first region image, wherein the first region imagecorresponds to the received view direction, wherein the first pixelcorresponds to the received mapping position, and wherein each cell ofthe table contains a position of a center of a respective piece of anellipsoid defined by the plurality of mirrors.
 19. The system of claim18, wherein calculating the indirect lighting color at the mappingposition using the data describing the physical material comprises:determining a first indirect lighting color at the mapping position,comprising: generating a first non-integer random number selected from arange of zero to K; generating a second non-integer random numberselected from a range of zero to M; indexing the table using the firstrandom number and the second random number to identify cells that boundthe first random number and the second random number; identifyingpositions contained in the identified cells; combining the positions togenerate a final position; and tracing a ray in the direction defined bythe final position to determine the first indirect lighting color; andcalculating the indirect lighting color at the mapping position based atleast in part on the first indirect lighting color.
 20. A non-transitorycomputer-readable medium storing instructions that when executed by oneor more computers cause the one or more computers to perform operationscomprising: obtaining data describing a physical material, wherein thedata describing the physical material includes a plurality of palettizedimages of a first sample of the physical material, wherein each of thepalettized images comprises a respective reflected image of the firstsample of the physical material reflected by a respective mirror of aplurality of mirrors; receiving a shading request to shade a particularpoint in a representation of the physical material, wherein the requestidentifies a mapping position of the particular point, a view directionat the mapping position, and a light direction at the mapping position;calculating a direct lighting color at the mapping position using theplurality of palettized images; calculating an indirect lighting colorat the mapping position using the data describing the physical material;generating a final color at the mapping position using the directlighting color and the indirect lighting color; and providing the finalcolor to a rendering engine.